package org.forever.view
{
	import flash.events.MouseEvent;
	import flash.geom.Point;
	
	import mx.core.UIComponent;
	import mx.logging.ILogger;
	import mx.logging.Log;
	
	/**折线用的线条边类*/
	public class BrokenLineEdge extends UIComponent
	{
		private static var _log:ILogger = Log.getLogger("org.forever.view.BrokenLineEdge");
		private var _fromPoint:Point;
		private var _toPoint:Point;
		private var _lineColor:uint=0x000000;
		private var _thickness:Number = 1;
		private var _alpha:Number = 1;
		private var _firstRect:BrokenLineRect;
		private var _secondRect:BrokenLineRect;
		private var _desc:String;
		
		public function BrokenLineEdge()
		{
			super();
			_fromPoint = new Point();
			_toPoint = new Point();
			addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
		}
		
		public function mouseDownHandler(e:MouseEvent):void{
			print();
		}
		
		public function print():void{
			_log.debug("*******************("+_desc+")信息************************************");
			_log.debug("第一个端点矩形："+_firstRect.desc);
			_log.debug("第二个端点矩形："+_secondRect.desc);
			_log.debug("*********************************************************************");
		}
		
		/**绘制线条*/
		public function drawLine():void{
			_log.debug("重绘边" + _desc + ";" + _firstRect.desc + ":" + _secondRect.desc);
			fromPoint.x = _firstRect.x + _firstRect.width/2;
			fromPoint.y = _firstRect.y + _firstRect.height/2;
			toPoint.x = _secondRect.x+_secondRect.width/2;
			toPoint.y = _secondRect.y + _secondRect.height/2;
			this.graphics.clear();
			this.graphics.lineStyle(_thickness,_lineColor,_alpha);
			this.graphics.moveTo(_fromPoint.x,_fromPoint.y);
			this.graphics.lineTo(_toPoint.x,_toPoint.y);
		}
		
		
		/**线起点*/
		public function get fromPoint():Point
		{
			return _fromPoint;
		}

		/**
		 * @private
		 */
		public function set fromPoint(value:Point):void
		{
			_fromPoint = value;
		}

		/**线终点*/
		public function get toPoint():Point
		{
			return _toPoint;
		}

		/**
		 * @private
		 */
		public function set toPoint(value:Point):void
		{
			_toPoint = value;
		}

		/**线条颜色*/
		public function get lineColor():uint
		{
			return _lineColor;
		}

		/**
		 * @private
		 */
		public function set lineColor(value:uint):void
		{
			_lineColor = value;
		}

		/**关联的第一个端点*/
		public function get firstRect():BrokenLineRect
		{
			return _firstRect;
		}

		/**
		 * @private
		 */
		public function set firstRect(value:BrokenLineRect):void
		{
			_firstRect = value;
		}

		/**关联的第二个端点*/
		public function get secondRect():BrokenLineRect
		{
			return _secondRect;
		}

		/**
		 * @private
		 */
		public function set secondRect(value:BrokenLineRect):void
		{
			_secondRect = value;
		}

		public function get desc():String
		{
			return _desc;
		}

		public function set desc(value:String):void
		{
			_desc = value;
		}


	}
}